package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurBindProject;
import com.js.purs.service.IPurBindProjectService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 招标项目Controller
 * 
 * @author lzq
 * @date 20240625
 */
@RestController
@RequestMapping("/bind")
public class PurBindProjectController extends BaseController
{
    @Autowired
    private IPurBindProjectService purBindProjectService;

    /**
     * 查询招标项目列表
     */
    @RequiresPermissions("purs:bind:list")
    @GetMapping("/list")
    public TableDataInfo list(PurBindProject purBindProject)
    {
        startPage();
        List<PurBindProject> list = purBindProjectService.selectPurBindProjectList(purBindProject);
        return getDataTable(list);
    }

    /**
     * 查询招标项目列表最新四条数据
     */
    @RequiresPermissions("purs:bind:list")
    @GetMapping("/listNewBest")
    public AjaxResult listNewBest(PurBindProject purBindProject)
    {

        List<PurBindProject> list = purBindProjectService.selectPurBindProjectListNewBest(purBindProject);
        return success(list);
    }

    /**
     * 导出招标项目列表
     */
    @RequiresPermissions("purs:bind:export")
    @Log(title = "招标项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurBindProject purBindProject)
    {
        List<PurBindProject> list = purBindProjectService.selectPurBindProjectList(purBindProject);
        ExcelUtil<PurBindProject> util = new ExcelUtil<PurBindProject>(PurBindProject.class);
        util.exportExcel(response, list, "招标项目数据");
    }

    /**
     * 获取招标项目详细信息
     */

    @GetMapping(value = "/{bindCode}")
    public AjaxResult getInfo(@PathVariable("bindCode") String bindCode)
    {
        return success(purBindProjectService.selectPurBindProjectByBindCode(bindCode));
    }

    /**
     * 新增招标项目
     */
    @RequiresPermissions("purs:bind:add")
    @Log(title = "招标项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurBindProject purBindProject)
    {
        return toAjax(purBindProjectService.insertPurBindProject(purBindProject));
    }

    /**
     * 修改招标项目
     */
    @RequiresPermissions("purs:bind:edit")
    @Log(title = "招标项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurBindProject purBindProject)
    {
        return toAjax(purBindProjectService.updatePurBindProject(purBindProject));
    }

    /**
     * 删除招标项目
     */
    @RequiresPermissions("purs:bind:remove")
    @Log(title = "招标项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bindCodes}")
    public AjaxResult remove(@PathVariable String[] bindCodes)
    {
        return toAjax(purBindProjectService.deletePurBindProjectByBindCodes(bindCodes));
    }
}
